package com.ming.controller;

import com.ming.common.Result;
import com.ming.common.validator.ValidatorUtil;
import com.ming.from.SysPermissionForm;
import com.ming.query.SysPermissionQuery;
import com.ming.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-04-13 22:03
 */
@RestController
@RequestMapping("sysper")
public class SysPermissionController {

    @Autowired
    private SysPermissionService sysPermissionService;

    /**
     * 查询所有的权限 用于左侧菜单的显示
     * @return
     */
    @RequestMapping("list.do")
    public Object list(){
        Result rs = sysPermissionService.queryList();
        return rs;
    }

    /**
     * 用户分页查询权限信息
     * @return
     */
    @RequestMapping("page.do")
    public Object page(SysPermissionQuery query){
        Result rs = sysPermissionService.doPage(query);
        return rs;
    }

    /**
     * 处理新增请求
     * @param form
     * @return
     */
    @RequestMapping("add.do")
    public Object add(SysPermissionForm form){
        ValidatorUtil.validator(form);
        Result rs = sysPermissionService.add(form);
        return rs;
    }

    /**
     * 修改
     * @param form
     * @return
     */
    @RequestMapping("update.do")
    public Object update(SysPermissionForm form){
        ValidatorUtil.validator(form);
        Result rs = sysPermissionService.update(form);
        return rs;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping("delete.do")
    public Object delete(Integer id){
        Result rs = sysPermissionService.delete(id);
        return rs;
    }


}
